package com.atguigu.gmall.model.list;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 *  映射对象   映射到ES索引库    Lucene实现在  Document文档类型  数据类型
 *   100万
 *     Master主 123      副本 replicas 2
 *     Master主 456      副本 replicas 2
 *     Master主 789      副本 replicas 2
 *      ES  自动 裂变
 *
 *      单机
 *
 */
@Document(indexName = "goods", type = "info", shards = 3, replicas = 2)
@Data
public class Goods implements Serializable {

    @Id
    private Long id;//sku_info  库存表ID  ES 索引是支持主键删除

    @Field(type = FieldType.Keyword, index = false)
    private String defaultImg;//type=FieldType 二种 分sku_info  库

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Date)
    private Date createTime; // 新品  保存索引的时候 现创建的 是什么时候 保存的索引

    @Field(type = FieldType.Long)
    private Long tmId;//base_trademark

    @Field(type = FieldType.Keyword)
    private String tmName;//base_trademark

    @Field(type = FieldType.Keyword)
    private String tmLogoUrl;//base_trademark

    @Field(type = FieldType.Long)
    private Long category1Id;//视图

    @Field(type = FieldType.Keyword)
    private String category1Name;

    @Field(type = FieldType.Long)
    private Long category2Id;

    @Field(type = FieldType.Keyword)
    private String category2Name;

    @Field(type = FieldType.Long)
    private Long category3Id;

    @Field(type = FieldType.Keyword)
    private String category3Name;

    @Field(type = FieldType.Long)
    private Long hotScore = 0L;//关注度 热度  默认0

    @Field(type = FieldType.Nested) //嵌套
    private List<SearchAttr> attrs;//平台属性集合

}
